package model

import (
	"gorm.io/gorm"
	"service/basic/config"
	"time"
)

type Cleaner struct { //清洁员表
	Id          uint           `gorm:"column:id;type:int UNSIGNED;primaryKey;not null;" json:"id"`
	Name        string         `gorm:"column:name;type:varchar(255);comment:保洁师姓名;not null;" json:"name"`                               // 保洁师姓名
	Price       uint           `gorm:"column:price;type:int UNSIGNED;comment:保洁师服务价格;not null;" json:"price"`                         // 保洁师服务价格
	CleanerType string         `gorm:"column:cleaner_type;type:varchar(255);comment:保洁师服务类型;not null;" json:"cleaner_type"`           // 保洁师服务类型
	CleanerTool uint           `gorm:"column:cleaner_tool;type:int UNSIGNED;comment:清洁工具;not null;" json:"cleaner_tool"`                 // 清洁工具
	Status      uint           `gorm:"column:status;type:int UNSIGNED;comment:保洁师状态：1待接单 2已接单;not null;default:1;" json:"status"` // 保洁师状态：1待接单 2已接单
	CreatedAt   time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (c *Cleaner) TableName() string {
	return "cleaner"
}

// 搜索
func (c *Cleaner) SearchCleanerType() error {
	return config.DB.Where("cleaner_type like ?", "%"+c.CleanerType+"%").Limit(1).Find(&c).Error
}

// 搜索
func (c *Cleaner) SearchStatus() error {
	return config.DB.Where("status = ?", 1).Limit(1).Find(&c).Error
}
